<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let len = 6;
        let nums = [2, 2, 1, 3, 4, 7, 7, 1];
        var maxSubArray = function (nums) {
            const memo = [];
            memo[0] = 1;
            let max = 1;

            for (let i = 1; i < nums.length; i++) {
                memo[i] = nums[i] >= nums[i - 1] ? memo[i - 1] + 1 : 1

                // 每生成一个memo[i]就与max比较
                max = Math.max(max, memo[i]);
            }
            console.log(memo)

            return max;
        };

        console.log(maxSubArray(nums));

    </script>
</body>

</html>